var __decorate = (this && this.__decorate) || function (a4, b4, c4, d4) {
    var e4 = arguments.length, f4 = e4 < 3 ? b4 : d4 === null ? d4 = Object.getOwnPropertyDescriptor(b4, c4) : d4, g4;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        f4 = Reflect.decorate(a4, b4, c4, d4);
    else
        for (var h4 = a4.length - 1; h4 >= 0; h4--)
            if (g4 = a4[h4])
                f4 = (e4 < 3 ? g4(f4) : e4 > 3 ? g4(b4, c4, f4) : g4(b4, c4)) || f4;
    return e4 > 3 && f4 && Object.defineProperty(b4, c4, f4), f4;
};
let LazyData = class LazyData {
    constructor(z3 = []) {
        this._data = [];
        this._listeners = [];
        this._data = z3;
    }
    setData(y3) {
        this._data = y3;
    }
    getDataIndex(x3) {
        if (typeof x3 == 'function') {
            return this._data.findIndex(x3);
        }
        return this._data.indexOf(x3);
    }
    pushData(w3) {
        this._data.push(w3);
        this.notifyDataAdd(this._data.length - 1);
    }
    deleteData(u3) {
        let v3 = -1;
        if (typeof u3 == 'number') {
            this._data.splice(u3, 1);
            v3 = u3;
        }
        else {
            v3 = this.getDataIndex(u3);
            this._data.splice(v3, 1);
        }
        this.notifyDataDelete(v3);
    }
    insertData(s3, t3 = 0) {
        this._data.splice(t3, 0, s3);
        this.notifyDataAdd(t3);
    }
    popData() {
        let r3 = this._data.pop();
        this.notifyDataDelete(this._data.length);
        return r3;
    }
    shiftData() {
        let q3 = this._data.shift();
        this.notifyDataDelete(0);
        return q3;
    }
    modifyData(n3, o3) {
        let p3 = -1;
        if (typeof n3 == 'number') {
            p3 = n3;
        }
        else {
            p3 = this.getDataIndex(n3);
        }
        this._data[p3] = o3;
        this.notifyDataChange(p3);
    }
    moveData(k3, l3) {
        let m3 = this._data[k3];
        this._data[k3] = this._data[l3];
        this._data[l3] = m3;
        this.notifyDataMove(k3, l3);
    }
    searchData(j3) {
        return this._data.filter(j3);
    }
    totalCount() {
        return this._data.length;
    }
    getData(i3) {
        return this._data[i3];
    }
    registerDataChangeListener(h3) {
        if (this._listeners.indexOf(h3) < 0)
            this._listeners.push(h3);
    }
    unregisterDataChangeListener(f3) {
        let g3 = this._listeners.indexOf(f3);
        if (g3 > 0)
            this._listeners.splice(g3, 1);
    }
    notifyDataReload() {
        this._listeners.forEach(e3 => {
            e3.onDataReloaded();
        });
    }
    notifyDataAdd(a3) {
        this._listeners.forEach(c3 => {
            c3.onDataAdd(a3);
        });
    }
    notifyDataMove(w2, x2) {
        this._listeners.forEach(z2 => {
            z2.onDataMove(w2, x2);
        });
    }
    notifyDataDelete(t2) {
        this._listeners.forEach(v2 => {
            v2.onDataDelete(t2);
        });
    }
    notifyDataChange(q2) {
        this._listeners.forEach(s2 => {
            s2.onDataChange(q2);
        });
    }
};
LazyData = __decorate([
    Observed
], LazyData);
export { LazyData };
